Skip to content

fix(test): validate artifact run id default path#47

Closed
Lexiie wants to merge 1 commit into
TestSprite:mainfrom
Lexiie:fix/artifact-runid-default-path-lexiie
Closed

fix(test): validate artifact run id default path#47
Lexiie wants to merge 1 commit into
TestSprite:mainfrom
Lexiie:fix/artifact-runid-default-path-lexiie

Conversation

@Lexiie

@Lexiie Lexiie commented Jun 26, 2026

Copy link
Copy Markdown

Summary

Fixes #45.

test artifact get <run-id> used the raw positional runId as the final segment of the default output directory:

./.testsprite/runs/<run-id>/

That made the implicit destination path interpret path-like run IDs as filesystem structure. For example, a value like ../../outside would normalize outside the documented .testsprite/runs/ artifact root when --out was omitted.

This PR treats runId as an opaque identifier for the implicit default path. If callers want a custom filesystem location, the existing explicit --out <dir> path remains the supported mechanism.

Changes

  • Add resolveDefaultArtifactDir(runId, cwd) for the implicit artifact output directory.
  • Reject path-like run IDs for the default path:
    • . / ..
    • /
    • \
    • NUL bytes
  • Keep normal run IDs on the documented path: ./.testsprite/runs/<run-id>/.
  • Move HTTP client construction until after local path validation and dry-run handling, so invalid local input fails before credentials, network, or disk work.
  • Add regression coverage for unsafe path-like run IDs and the normal default path.

Why

test artifact get writes a multi-file failure bundle. The documented default path implies containment under .testsprite/runs/, while --out is already available for intentional custom paths. Failing closed on path-like positional IDs keeps the default artifact tree predictable and avoids surprising local writes.

Verification

  • npx vitest run src/commands/test.artifact.spec.ts
  • npm run typecheck

@zeshi-du

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@zeshi-du, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e9a39b88-6db4-4187-8de3-9a1227055d9f

📥 Commits

Reviewing files that changed from the base of the PR and between 15e95de and 33ed2de.

📒 Files selected for processing (2)
  • src/commands/test.artifact.spec.ts
  • src/commands/test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@zeshi-du

zeshi-du commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Thanks for the security-minded fix, @Lexiie! 🙏

#71 guards the artifact runId path the same way and additionally handles the Windows trimmed-dot bypass (. / .. ), so we're consolidating on #71 and closing this as a duplicate in its favor.

Genuinely appreciate the contribution — please keep them coming! 🚀

@zeshi-du zeshi-du closed this Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(test): prevent path-like run IDs escaping artifact default output dir

2 participants